package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesPallet;
import com.ruoyi.order.service.IMesPalletService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 托盘管理Controller
 * 
 * @author guoxl
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/order/pallet")
public class MesPalletController extends BaseController
{
    @Autowired
    private IMesPalletService mesPalletService;

    /**
     * 查询托盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesPallet mesPallet)
    {
        startPage();
        List<MesPallet> list = mesPalletService.selectMesPalletList(mesPallet);
        return getDataTable(list);
    }

    /**
     * 导出托盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:export')")
    @Log(title = "托盘管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesPallet mesPallet)
    {
        List<MesPallet> list = mesPalletService.selectMesPalletList(mesPallet);
        ExcelUtil<MesPallet> util = new ExcelUtil<MesPallet>(MesPallet.class);
        util.exportExcel(response, list, "托盘管理数据");
    }

    /**
     * 获取托盘管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesPalletService.selectMesPalletById(id));
    }

    /**
     * 新增托盘管理
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:add')")
    @Log(title = "托盘管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesPallet mesPallet)
    {
        return toAjax(mesPalletService.insertMesPallet(mesPallet));
    }

    /**
     * 修改托盘管理
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:edit')")
    @Log(title = "托盘管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesPallet mesPallet)
    {
        return toAjax(mesPalletService.updateMesPallet(mesPallet));
    }

    /**
     * 删除托盘管理
     */
    @PreAuthorize("@ss.hasPermi('order:pallet:remove')")
    @Log(title = "托盘管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesPalletService.deleteMesPalletByIds(ids));
    }
}
